package com.lambda.springbootlambda.aggregate;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;

/**
 * @author ytj
 * @date 2021/12/15
 */
public class AggregateTest {
    public static void main(String[] args) {

//        AggregateTest.foreachTest(list);
//        AggregateTest.del();
        AggregateTest.sort();
    }

    /**
     * 集合遍历
     * */
    public static void foreachTest(){
        List<Integer> list=new ArrayList<>();
        Collections.addAll(list,1,2,3,4,5);
        list.forEach(System.out::println);
        list.forEach(data->{
            System.out.println(data);
        });
    }

    /**
     * 删除值
     * */
    public static void del(){
        List<Integer> list=new ArrayList<>();
        Collections.addAll(list,1,2,3,4,5);
        list.removeIf(data->data==1);
        list.forEach(System.out::println);
    }

    /**
     * 比较大小
     * */
    public static void sort(){
        List<Integer> list=new ArrayList<>();
        Collections.addAll(list,3,2,4,5,1);
        list.sort((o1,o2)->o1-o2);
        list.forEach(System.out::println);
    }


}
